﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace EHTWebsiteProject
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ltrText.Text = CreateAllButton("http://www.codeproject.com/Articles/292139/Adding-Social-Buttons-Twitter-facebook-Google-plus", "Vu trong toan");
        }

        private String CreateTwitter(String url, String title)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<a ");
            sb.Append("hreft='https://twitter.com/share' class='twitter-share-button' data-via='MY-TWITTER-HANDLE' data-count='horizontal' ");
            sb.Append("data-text = '" + title + "' ");
            sb.Append("data-url = '" + url + "' >");
            sb.Append("Tweet");
            sb.Append("</a>");

            return sb.ToString();
        }

        private String CreateFaceBook(String url, String title)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<div ");
            sb.Append("class='fb-like' data-send='false' data-layout='button_count' data-show-faces='false' data-font='arial' ");
            sb.Append("data-href = '" + url + "' >");
            sb.Append("</div>");

            return sb.ToString();
        }

        private String CreateGooglePlusOne(String url, String title)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<div ");
            sb.Append("class='g-plusone' data-size='medium' ");
            sb.Append("data-href = '" + url + "' >");
            sb.Append("</div>");

            return sb.ToString();
        }

        public String CreateAllButton(String url, String title)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<ul class='social'>");

            // google +
            sb.Append("<li class='social-google'>");
            sb.Append(CreateGooglePlusOne(url, title));
            sb.Append("</li>");

            // Twitter +
            sb.Append("<li class='social-twitter'>");
            sb.Append(CreateTwitter(url, title));
            sb.Append("</li>");

            // Facebook +
            sb.Append("<li class='social-facebook'>");
            sb.Append(CreateFaceBook(url, title));
            sb.Append("</li>");

            sb.Append("</ul>");

            return sb.ToString();
        }
    }
}